// 测试数据格式修复
const testDataFormats = () => {
  console.log('=== 测试数据格式修复 ===')
  
  // 模拟后端返回的Result格式数据
  const mockResultData = {
    code: 200,
    message: "操作成功",
    data: {
      records: [
        {
          orderId: 1,
          bizType: "门诊充值",
          amount: 100.00,
          operateTime: "2024-01-01 10:00:00",
          orderNumber: "CZ202401011000001",
          payMethod: "微信支付",
          payStatus: 1
        }
      ],
      total: 1,
      size: 20,
      current: 1
    }
  }
  
  // 模拟前端处理逻辑
  let rechargeData = mockResultData
  
  // 检查是否为Result格式的响应
  if (rechargeData.code !== undefined) {
    if (rechargeData.code !== 200) {
      console.error('后端返回错误:', rechargeData.message)
      return
    }
    // 从Result.data中提取实际数据
    rechargeData = rechargeData.data
  }
  
  // 提取数据数组
  let dataList = []
  if (Array.isArray(rechargeData)) {
    dataList = rechargeData
  } else if (rechargeData && rechargeData.records && Array.isArray(rechargeData.records)) {
    // 处理MyBatis-Plus分页数据
    dataList = rechargeData.records
  } else if (rechargeData && rechargeData.data && Array.isArray(rechargeData.data)) {
    dataList = rechargeData.data
  } else if (rechargeData && rechargeData.list && Array.isArray(rechargeData.list)) {
    dataList = rechargeData.list
  } else if (rechargeData && rechargeData.content && Array.isArray(rechargeData.content)) {
    // 处理其他分页数据
    dataList = rechargeData.content
  } else {
    console.error('数据格式不正确:', rechargeData)
    return
  }
  
  console.log('✅ 数据格式处理成功')
  console.log('提取的数据:', dataList)
  
  // 检查分页信息
  if (rechargeData && rechargeData.total !== undefined) {
    const total = rechargeData.total || 0
    const current = rechargeData.current || 1
    const size = rechargeData.size || 20
    const hasMore = (current * size) < total
    console.log('分页信息:', { total, current, size, hasMore })
  }
}

// 运行测试
testDataFormats() 